import React, { Component, createRef } from 'react'

const Fn = () => {
  return (
    <h1>函数式组件</h1>
  )
}
class ChildCom extends Component {
  render () {
    return (
      <h1>类组件</h1>
    )
  }
}
export default class App extends Component {
  divRef = createRef()
  fnRef = createRef()
  childRef = createRef()
  render() {
    return (
      <div>
        <div ref = { this.divRef }>您好</div>
        <Fn ref = {this.fnRef}/>
        <ChildCom ref = { this.childRef }/>
        <button onClick = { () => {
          console.log(this.divRef)
          console.log(this.fnRef)
          console.log(this.childRef)
        }}>获取</button>
      </div>
    )
  }
}
